package lm.concurrency.day4;

import lm.concurrency.util.Sleeper;

/**
 * @Auther: Min.Liu
 * @Description: 可见性相关
 * @Date: Created in 16:56 2024/11/6
 */
public class VisibilityRelated {
    static volatile boolean run = true;
    public static void main(String[] args) {

        Thread thread = new Thread() {
            @Override
            public void run() {
                while (run) {
                    //System.out.println("重复执行");
                }
                //System.out.println("收到暗示，已停止");
            }
        };
        thread.start();
        Sleeper.sleep(1);
        //run = false;
        Thread thread2 = new Thread() {
            @Override
            public void run() {
                run = false;
            }
        };
        thread2.start();
    }
}
